-- wear_bonus
-- create by zhuangsl
-- 首次穿戴奖励XX

return {
    apply = function(prop, baseValue)
        -- 数量
        return prop[3];
    end,

    record = function(target, prop, path)
        return false;
    end,

    -- 穿戴装备触发
    trigger = function(who, prop, classId)
        local attrib = prop[2];
        local propId = tonumber(prop[1]);
        local v = tonumber(prop[3]);

        -- 预先处理一下
        if not EquipM.doWearTrigger(who, classId, propId, attrib) then
            return 0;
        end

        local bonus = { iif(type(attrib) == "number", 1, 2), attrib, v, };
        BonusM.doBonus(bonus, "wear_bonus");

        return v;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local attrib = prop[2];
        if type(attrib) == 'string' and prop[2] ~= "search_point" then
            desc = row.append_desc;
        end

        local num = prop[3];
        local attrib = FieldsM.getFieldName(prop[2]);
        if attrib then
            desc = string.gsub(desc, "{0}", attrib);
        else
            local item = ItemM.query(prop[2], "name");
            desc = string.gsub(desc, "{0}", item);
        end
        desc = string.gsub(desc, "{1}", num);

        return desc;
    end,
};
